/* Reset and base styles for consistent rendering across browsers */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    /* Responsive height - 450px in iframe, 90vh in new tab */
    height: 450px;
    overflow: hidden;
}

/* Check if running in new tab (larger viewport) */
@media screen and (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main container with proper spacing and layout */
.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 8px;
    gap: 8px;
}

/* Control panel styling for parameter adjustment */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: space-between;
}

/* Control group styling for organized layout */
.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.control-group label {
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

.control-group select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    background: white;
    min-width: 140px;
}

/* Slider container for parameter adjustment */
.sliders-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.slider-group label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

/* Custom slider styling for better visual feedback */
.slider-group input[type="range"] {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #5a6fd8;
    transform: scale(1.1);
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Toggle button group for show/hide functionality */
.toggle-group {
    display: flex;
    gap: 6px;
}

.toggle-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #666;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toggle-btn:hover {
    background: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Control buttons for zoom and reset */
.control-btn {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #666;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.control-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Graph container for dual canvas layout */
.graph-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.graph-wrapper {
    position: relative;
    flex: 1;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.graph-wrapper canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}

/* Graph labels for identification */
.graph-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Information panel for displaying values and equations */
.info-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
}

#mouseInfo {
    color: #666;
    font-style: italic;
}

#equationDisplay, #derivativeDisplay {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #333;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        gap: 8px;
    }
    
    .sliders-container {
        justify-content: center;
        width: 100%;
    }
    
    .toggle-group, .control-group {
        justify-content: center;
        width: 100%;
    }
    
    .info-panel {
        flex-direction: column;
        text-align: center;
    }
    
    /* Increase touch target sizes for mobile */
    .toggle-btn, .control-btn {
        padding: 8px 12px;
        min-height: 44px;
        font-size: 12px;
    }
    
    .slider-group input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }
}

/* Tooltip styling for additional information */
[title] {
    position: relative;
}

/* Animation for smooth transitions */
.graph-wrapper {
    transition: transform 0.2s ease;
}

.graph-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Loading state styling */
.loading {
    opacity: 0.6;
    pointer-events: none;
}